<template>
<div>
    <h1>添加分类</h1>
  分类名：<input type="text" v-model="name">
  所属分类：
  <select v-model="parent">
      <option value="">空</option>
      <option v-for="i in cate1_list">{{i.name}}</option>
  </select>
  所属组：<input type="text" v-model="group">
  <button @click="add()">添加</button>
</div>
  
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            name:"",
            parent:"",
            group:"",
            cate1_list:[]
        }
    },methods: {
        add(){
            var data={
                "name":this.name,
                "parent":this.parent,
                "group":this.group,
            }
            axios({
                url:"http://127.0.0.1:8000/cate1",
                data:data,
                method:"post"
            }).then(resp=>{
                console.log(resp.data)
                alert(resp.data.msg)
            })
        },
        bala(){
            axios({
                url:"http://127.0.0.1:8000/cate1",
                method:"get"
            }).then(resp=>{
                console.log(resp.data)
                this.cate1_list = resp.data
            })
        }
    },created() {
        this.bala()
    },
}
</script>

<style>

</style>